package com.newhero.product.module.sys.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.newhero.product.common.controller.BaseController;
import com.newhero.product.common.mybatis.mapper.EntityWrapper;
import com.newhero.product.common.mybatis.plugins.Page;
import com.newhero.product.common.util.StringUtils;
import com.newhero.product.module.sys.model.Mlog;
import com.newhero.product.module.sys.service.IMlogService;

/**
 * @ClassName: MlogController 
 * @Description: 系统日志查看类 
 * @author Caolj 648198687@qq.com 
 * @date 2017-4-7 上午9:17:14
 */
@Controller
@RequestMapping("/admin")
public class MlogController extends BaseController {
	@Autowired
	private IMlogService mlogServiceImpl;

	@RequiresPermissions("/admin/mlog") 
	@RequestMapping(value = "/mlog")
	public String mlog(
			@RequestParam(value = "page", defaultValue = "1", required = true) int page,// 页号
			@RequestParam(value = "rows", defaultValue = "" + _ROWS_PER_PAGE, required = true) int rows,// 每页显示的记录条数
			@RequestParam(value = "cznr", required = false, defaultValue = "") String cznr,
			@RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
			HttpServletRequest request, HttpServletResponse response,
			ModelMap model) {
		Page<Mlog> data = new Page<Mlog>();
		data.setCurrent(page);
		data.setSize(rows);
		data.setOrderByField("mlogTime");
		data.setAsc(false);
		EntityWrapper<Mlog> wrapper = new EntityWrapper<Mlog>();
		if(StringUtils.isNotBlank(cznr)){
			wrapper.like("mlogContent", cznr);
		}
		if(StringUtils.isNotBlank(startDate)){
			wrapper.like("mlogTime",startDate);
		}		
		data = mlogServiceImpl.selectPage(data, wrapper);
		model.addAttribute("data", data);
		model.addAttribute("startDate", startDate);
		model.addAttribute("cznr", cznr);
		return "sys/mlog/mlog";
	}

}
